<?php


namespace App\Admin\Extensions;

use Encore\Admin\Admin;

class TestReport
{
    protected $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

    protected function script()
    {
        return <<<SCRIPT
        
        o_window = function(id){
            var wi = window.open('about:blank', '_blank');

            var domain = window.location.host;
            wi.location.href = 'http://'+domain+'/admin/report/test_report?id='+id;
        };

SCRIPT;
    }

    protected function render()
    {
        Admin::script($this->script());

        return "<a class='fa fa-file-powerpoint-o grid-check-row' data-id='{$this->id}' onclick='o_window(".$this->id.");'></a>";
    }

    public function __toString()
    {
        return $this->render();
    }
}